package com.xjtu.controller.user;

import com.xjtu.dto.care.AddCareRecordDto;
import com.xjtu.dto.serviceRecord.AddServiceRecordDto;
import com.xjtu.result.Result;
import com.xjtu.service.CareRecordService;
import com.xjtu.service.ServiceRecordService;
import com.xjtu.vo.serviceRecord.ServiceRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/user/service")
@Slf4j
@Api(tags = "用户端服务记录接口")
public class UserServiceController {
    @Autowired
    private CareRecordService careRecordService;

    @Autowired
    private ServiceRecordService serviceRecordService;

    @PostMapping("/care")
    @ApiOperation("新增一条护理记录")
    public Result saveCare(@RequestBody @Valid AddCareRecordDto addCareRecordDto){
        careRecordService.save(addCareRecordDto);
        return Result.success();
    }

    @PostMapping
    @ApiOperation("新增一条服务记录")
    public Result<ServiceRecordVo> saveService(@RequestBody @Valid AddServiceRecordDto addServiceRecordDto) {
        ServiceRecordVo resp = serviceRecordService.save(addServiceRecordDto);
        return Result.success(resp);
    }

}
